/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package cn.ac.iie.di.wx.startup;

import cn.ac.iie.di.wx.common.RuntimeEnv;
import cn.ac.iie.di.wx.httpservice.HttpGetter;
import static cn.ac.iie.di.wx.startup.CplStart.init;
import cn.ac.iie.di.wx.utils.DateUtil;
import cn.ac.iie.di.wx.utils.RedisUtil;
import java.util.logging.Level;
import org.apache.log4j.Logger;

/**
 *
 * @author Administrator
 */
public class CplQuery {

    static Logger logger = Logger.getLogger(CplQuery.class.getName());

    public static void main(String[] args) {
        try {
            init();
            HttpGetter httpGetter = new HttpGetter();

            String redisHosts = ((String) RuntimeEnv.getParam(RuntimeEnv.REDIS_HOSTS));
            String masterName = (String) RuntimeEnv.getParam(RuntimeEnv.REDIS_MASTER_NAME);
            String dbName = (String) RuntimeEnv.getParam(RuntimeEnv.REDIS_DB_NAME);

            String user = (String) RuntimeEnv.getParam(RuntimeEnv.USER);
            String password = (String) RuntimeEnv.getParam(RuntimeEnv.PASSWORD);

            RedisUtil userRedisUtil = new RedisUtil(redisHosts, masterName, Integer.parseInt(dbName));

            logger.info("date:" + (String) RuntimeEnv.getParam(RuntimeEnv.DATE) + "\tthe day before" + DateUtil.getTheDayBeforeDate((String) RuntimeEnv.getParam(RuntimeEnv.DATE)));
            String theDayBeforeDataSize = userRedisUtil.get((String) RuntimeEnv.getParam(RuntimeEnv.DATASIZE)
                    + DateUtil.getTheDayBeforeDate((String) RuntimeEnv.getParam(RuntimeEnv.DATE)));
            String yesterdayDataSize = userRedisUtil.get((String) RuntimeEnv.getParam(RuntimeEnv.DATASIZE)
                    + (String) RuntimeEnv.getParam(RuntimeEnv.DATE));
            String allCount = userRedisUtil.get((String) RuntimeEnv.getParam(RuntimeEnv.ALLCOUNT)
                    + (String) RuntimeEnv.getParam(RuntimeEnv.DATE));
            String successCount = userRedisUtil.get((String) RuntimeEnv.getParam(RuntimeEnv.SUCCESSCOUNT)
                    + (String) RuntimeEnv.getParam(RuntimeEnv.DATE));
            logger.info((String) RuntimeEnv.getParam(RuntimeEnv.DATASIZE) + (String) RuntimeEnv.getParam(RuntimeEnv.DATE) + "=" + yesterdayDataSize);
            logger.info((String) RuntimeEnv.getParam(RuntimeEnv.DATASIZE) + DateUtil.getTheDayBeforeDate((String) RuntimeEnv.getParam(RuntimeEnv.DATE)) + "=" + theDayBeforeDataSize);
            logger.info((String) RuntimeEnv.getParam(RuntimeEnv.ALLCOUNT) + (String) RuntimeEnv.getParam(RuntimeEnv.DATE) + "=" + allCount);
            logger.info((String) RuntimeEnv.getParam(RuntimeEnv.SUCCESSCOUNT) + (String) RuntimeEnv.getParam(RuntimeEnv.DATE) + "=" + successCount);

        } catch (Exception ex) {
            java.util.logging.Logger.getLogger(CplStart.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
